24 #define foreach(x, v) for (typeof (v).begin() x=(v).begin(); x !=(v).end(); ++x)
25 #define For(i, a, b) for (int i=(a); i<(b); ++i)
26 #define D(x) cout << #x " is " << x << endl
28 const double EPS
= 1e-9;
29 int cmp(double x
, double y
= 0, double tol
= EPS
) {
30 return (x
<= y
+ tol
) ? (x
+ tol
< y
) ? -1 : 0 : 1;
35 point(double x
, double y
) : x(x
), y(y
) {}
37 bool operator < (const point
&p
) const {
38 int t
= cmp(this->x
, p
.x
);
39 if (t
!= 0) return t
< 0;
40 return cmp(this->y
, p
.y
) < 0;
44 point
center(const point
&p
, const point
&q
, const point
&r
) {
45 double ax
= q
.x
- p
.x
;
46 double ay
= q
.y
- p
.y
;
47 double bx
= r
.x
- p
.x
;
48 double by
= r
.y
- p
.y
;
49 double d
= ax
*by
- bx
*ay
;
52 printf("p = <%lf, %lf>, q = <%lf, %lf>, r = <%lf, %lf>\n", p
.x
, p
.y
, q
.x
, q
.y
, r
.x
, r
.y
);
53 printf("Points are collinear!\n");
57 double cx
= (q
.x
+ p
.x
) / 2;
58 double cy
= (q
.y
+ p
.y
) / 2;
59 double dx
= (r
.x
+ p
.x
) / 2;
60 double dy
= (r
.y
+ p
.y
) / 2;
62 double t1
= bx
*dx
+ by
*dy
;
63 double t2
= ax
*cx
+ ay
*cy
;
65 double x
= (by
*t2
- ay
*t1
) / d
;
66 double y
= (ax
*t1
- bx
*t2
) / d
;
75 while (scanf("%d", &n
) == 1) {
78 for (int i
= 0; i
< n
; ++i
) {
79 scanf("%lf %lf", &points
[i
].x
, &points
[i
].y
);
88 for (int i
= 0; i
< n
; ++i
) {
89 for (int j
= i
+ 1; j
< n
; ++j
) {
90 map
<point
, int> times
;
91 for (int k
= 0; k
< n
; ++k
) {
92 if (k
== i
or k
== j
) continue;
93 double x0
= points
[i
].x
- points
[k
].x
;
94 double y0
= points
[i
].y
- points
[k
].y
;
95 double x1
= points
[j
].x
- points
[k
].x
;
96 double y1
= points
[j
].y
- points
[k
].y
;
97 if ( cmp(x0
*y1
- y0
*x1
, 0) == 0 ) continue; // collinear
98 point c
= center(points
[i
], points
[j
], points
[k
]);
100 ans
= max(ans
, times
[c
] + 2);